<template>

    <div id="aduser">
        <g-admin></g-admin>
        <h1>编辑用户</h1>
        <el-table :data="tableData" border="true" style="width: 100%">
            <el-table-column label="头像" prop="userPhoto">
                <template slot-scope="scope">
                    <div class="block">
                        <el-avatar v-if="scope.row['userPhoto']" :size="50" :src="'http://localhost:8080'+scope.row['userPhoto']"></el-avatar>
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="userName" label="用户名" width="150px"></el-table-column>
            <el-table-column label="邮箱" prop="email"></el-table-column>
            <el-table-column label="电话" prop="phoneNumber"></el-table-column>
            <el-table-column label="信誉分" prop="userGrade"></el-table-column>
            <el-table-column label="操作" width="180px">
                <template slot-scope="scope">
                    <!-- 修改按钮 -->
                    <el-button @click="edit" type="text" size="small">修改信誉分</el-button>
                </template>
            </el-table-column>
        </el-table>

    </div>

</template>

<script>
    import GAdmin from '../../components/gadmin/GAdmin';
    import axios from 'axios'
    export default {
        components:{
            GAdmin
        },
        data() {
            return {
                tableData:[{
                    userName: '',
                    userPassword:'',
                    email:'',
                    phoneNumber:'',
                    userGrade:'',
                    userPhoto:''
                }
                ]
            }
        },
        created() {

            this.request({
                url:'http://127.0.0.1:8080/user/findall'
            }).then(res=>{
                this.tableData = res.data;
                // console.log("http://localhost:8080"+this.tableData.userPhoto);
                //console.log(this.tableData);
            }).catch(err=>{
                console.log(err);
            });

        },
        mounted(){
            document.querySelector('.tabbar').setAttribute('style','display:none');
            document.querySelector('.gfooter').setAttribute('style','display:none');
        },
        methods: {
            edit(){
                this.$router.push('/admin/admin/update').catch(error=>error)
            },
            getUserList(){
                let username = this.tableData.userName;
                this.request({
                    url:'http://127.0.0.1:8080/user/finduser/'+username
                }).then(res=>{
                    this.tableData = res.data;
                    console.log(this.tableData);
                }).catch(err=>{
                    console.log(err);
                })

            }
        }
    }
</script>

<style scoped>

    #aduser{
        width: 90%;
        margin-left: 10%;
        margin-top: 40px;
        background-color: #eaffea;
    }


</style>